#include "PCH.h"
#include "InputAssemberStage.h"
using namespace DeviousRenderer;

InputAssemberStage::InputAssemberStage()
	: m_eFeatureLevel(D3D_FEATURE_LEVEL_9_1)
{

}

InputAssemberStage::~InputAssemberStage()
{

}

void InputAssemberStage::SetFeatureLevel(D3D_FEATURE_LEVEL level)
{
	m_eFeatureLevel = level; 
}

void InputAssemberStage::SetIndexBuffer(int buffer, DXGI_FORMAT format /* = DXGI_FORMAT_R32_UINT */)
{
	m_iIndexBuffer = buffer;
	m_eIndexBufferFormat = format;
}

void InputAssemberStage::SetInputLayeout(int layout)
{
	m_iInputLayout = layout;
}

void InputAssemberStage::SetVertexBuffer(UINT slot, int buffer, UINT offset, UINT stride)
{
	if (slot < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT)
	{
		m_iVertexBuffers[slot] = buffer;
		m_uiVertexOffsets[slot] = offset;
		m_uiVertexStrides[slot] = stride;

	}
}



void InputAssemberStage::ClearState()
{
	SetIndexBuffer(-1);
	for (int i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i ++)
	{
		SetVertexBuffer(i, -1, 0, 0);
	}
	SetInputLayeout(-1);
	SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED);
}